import request from "@/utils/request";
import { AxiosPromise } from "axios";
import { ApprovalOptions, ApprovalPage, ApprovalQuery } from "./types";

export function getOptions(): AxiosPromise<ApprovalOptions[]> {
  return request({
    url: "/admin/approval/getOptions",
    method: "get",
  });
}

/**
 * 获取分页列表
 *
 * @param queryParams
 */
export function getApprovalPage(
  queryParams: ApprovalQuery
): AxiosPromise<PageResult<ApprovalPage[]>> {
  return request({
    url: "/admin/approval/index",
    method: "get",
    params: queryParams,
  });
}

/**
 * 获取表单详情
 *
 * @param ids
 */
export function getApprovalForm(ids: number): AxiosPromise<ApprovalPage> {
  return request({
    url: "/admin/approval/edit",
    method: "get",
    params: {
      ids: ids,
    },
  });
}

/**
 * 添加
 *
 * @param data
 */
export function addApproval(data: any) {
  return request({
    url: "/admin/approval/add",
    method: "post",
    data: data,
  });
}

/**
 * 删除
 *
 * @param data
 */
export function deleteApproval(data: any) {
  return request({
    url: "/admin/approval/del",
    method: "delete",
    data,
  });
}

/**
 * 删除
 *
 * @param data
 */
export function revokeApproval(data: any) {
  return request({
    url: "/admin/approval/revoke",
    method: "put",
    data,
  });
}
